<template>
	<div class="hello">
		<h1>{{ msg }}</h1>
		<h2>Essential Links</h2>
		<div class="btn1" @click="init">验证开发者</div>
		<div class="btn" @click="test">c测试</div>	</div>
</template>
<script>
	export default {
		name: 'HelloWorld',
		data() {
			return {
				msg: 'Welcome to Your Vue.js App',
				apiId: '',
				rqs: '',
				rsp: '',
				password: '',
				subKeyPad3: {}
			}
		},
		mounted() {
			// if (!localStorage.getItem('themeColor')) {
			// 	document.body.style.setProperty("--themeColor", "#FA4F40");
			// 	localStorage.setItem('themeColor', "#FA4F40");
			// } else {
			// 	localStorage.setItem('themeColor', "#FA4F40");
			// }
			this.getInit()
		},
		methods: {
			getInit() {
                console.log(123);
            // this.$toast.loading({
            //     duration: 0,
            //     message: '加载中...',
            //     forbidClick: true,
            // });
            let urlMsg = '';
            console.log(window.location.href.indexOf('localhost'));
            // 16.193
            if (window.location.href.indexOf('localhost') != -1 || window.location.href.indexOf('3.1.21') != -1) {
                urlMsg =
                    'sgn=MEYCIQCZFdmhIzDq6x95RZbZHyj2cwCjAZRzQvc/Ft0o9BdoDwIhAIDpOdxylYqQFH0eRIR1sQkRveuyxfXzFGHpR5lVzfqU&data=MGY0ZTU1MGQ4ZjQyNGJlYzgwODkwNGUwY2NlOTYyYTd8MTYwNTYwNzY4ODk4NHxhMzhkNjRjMGMzYTVlYWI2fDMuMS4xNS4yMDA=&param=Wj3/trbnFBuI3jYOosEhEoPRCl9L3Ic/PGjWT/6ARf+jbA2FXfEcUAOSgNitRYrqxAMmoQoKdlnl35QN0hpWWzOCCjmx0FspUH3ABUszHQJAWFcPW1NW9sux11rv4LHEnsvBtGHMp8bH6h+2ujB/ef5SQkgi6wt8Qa5OvdGb+PNxL+/vTsjcPmPEvTiDwTzO45Xm9GAjVAYkpGDiWE8tETsCpJ2o5E7CRwA1Yuy+K1Qax07aEU/kgKDQ2Skemtcv7FcPw/F25wW/9sHcWxF0XO2IMLQ157xf0pTbaOrp7eYc/BsO6JFycvdOrQmLtu4NUIC8iplxscjOL1yhwVFqBw=&param={"Rsrv0":"111111","Rsrv1":"222222"}';

            } else {
                urlMsg = decodeURIComponent(window.location.search.substr(1));
            }
            console.log(urlMsg);

            let itemObj = new Object();
            urlMsg.split('&').forEach(item => {
                itemObj[item.split('=')[0]] = item.split('=')[1];
            });
            console.log(itemObj);

            this.$api.init().then(res => {
                console.log(res);
                console.log(itemObj.param.indexOf('{'));
                console.log(JSON.parse(itemObj.param));
                if (res.Head.RspCd === '000000' && itemObj.param.indexOf('{') === -1) {
                    this.getSendMsg(res.Data.Param);
                } else if (res.Head.RspCd === '000000' && itemObj.param.indexOf('{') !== -1) {
                    this.getSendMsg(JSON.parse(itemObj.param));
                } else {
                    this.$toast({
                        title: '提示',
                        message: res.Head.RspInf
                    });
                }
            });
        },
        getSendMsg(msg) {
            let param = msg;
            this.cs1 = param.Rsrv0; // 参数1
            this.cs2 = param.Rsrv1; // 参数2
            console.log(this.cs1);
        },
			test() {
				var params = {
					PactNo: 'MCONL20220709123456',
					AgnOrg: '1163'
				};
				let header = {};
				return window.LNRCBSDK.send(
					`/AssEntLoan/HandleAgencyQry`,
					header,
					params
				).then(res => {
					this.rsp = JSON.stringify(res)
					console.log(res)
				})
			},
			init() {
				this.$api.init().then(res => {
					console.log('验证开发者',res)
				})
			}
		}
	}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped >
	/* .hello {
		height: 100vh;
		.btn1 {
			margin: 40px 4%;
			width: 92%;
			height: 40px;
			line-height: 40px;
			text-align: center;
			border-radius: 6px;
			color: @text-color;
			background-color: @btn-background-color;
			font-size: 14px;
		}
		.btn {
			// position: fixed;
			bottom: 3rem;
			margin: 40px 4%;
			width: 92%;
			height: 40px;
			line-height: 40px;
			text-align: center;
			border-radius: 6px;
			color: @text-color;
			background-color: @btn-background-color;
			font-size: 14px;
		}
	}
	h1, h2 {
		font-weight: normal;
	}
	.RqsTest {
		border-top: 1px solid #ccc;
		border-bottom: 1px solid #ccc;
	} */
</style>
